//
//  HomeProdTitleView.m
//  JiaoX
//
//  Created by 尹桥印 on 14/11/15.
//  Copyright (c) 2014年 北京娇羞科技有限公司. All rights reserved.
//  首页商品顶部view

#import "HomeProdTitleView.h"
#import "UIImageView+WebCache.h"

@interface HomeProdTitleView()
{
    UIImageView *imageView;
    UILabel *label;
}
@end
@implementation HomeProdTitleView
-(instancetype)initWithIconUrl:(NSString *)iconUrl Title:(NSString *)title{
    self = [super init];
    if(self!=nil){
        //添加imageview
        imageView = [[UIImageView alloc]init];
        [self addSubview:imageView];
        int width = 20;
        if([Utils isBlankString:iconUrl]){
            width = 0;
        }else{
            [imageView sd_setImageWithURL:[NSURL URLWithString:iconUrl]];
        }
        imageView.frame = CGRectMake(JXPublicInset, JXPublicInset, width, width);
        label = [[UILabel alloc]init];
        [label setFont:[UIFont systemFontOfSize:15]];
        CGFloat labelX = CGRectGetMaxX(imageView.frame)+JXPublicInset;
        CGFloat labelY = imageView.y+2.5;
        CGSize labelSize = [title sizeWithFont:[UIFont systemFontOfSize:15]];
        label.frame = (CGRect){{labelX,labelY},labelSize};
        label.text = title;
        [self addSubview:label];
        self.frame = CGRectMake(0, 0, JXScreenW, CGRectGetMaxY(label.frame));
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

@end
